package com.wlient.demo.controller;

import com.wlient.demo.service.mqtt.MqttConnectService;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @author: 史炜立
 * @description: TODO
 * @date: 2022/7/22 15:15
 */
@Controller
@RequestMapping("mqtt")
public class MqttConttroller {
    @Autowired
    public MqttConnectOptions mqttConnectOptions;

    @Autowired
    public MqttConnectService mqttConnectService;

    @GetMapping("/test")
    public void test() throws MqttException {
        mqttConnectService.pub("com/iot/init", "熊哥你好！*");
    }
}
